/**
 * @file FloodFillCommand.cpp
 *
 * @date 25/12/2011
 * @author Tales 
 *
 */

#include "FloodFillCommand.hpp"
#include "PictureState.hpp"
#include "../Graphics.hpp"

namespace yep
{

FloodFillCommand::FloodFillCommand(const pair<int, int> & pos, const Color &color_, int layer_) :
		Command(color_, layer_), position(pos)
{
}

void FloodFillCommand::execute(PictureState & picture)
{
	if (position.first >= 0 && position.second >= 0 && position.first < picture.getW()
			&& position.second < picture.getH())
	{
		Graphics g(picture.getLayer(getLayerIndex()).getSurface());
		g.setColor(getColor());
		g.floodFill(position);
	}
}

}

/* namespace yep */
